#!/bin/bash
# 安装nginx
if ! which nginx 2>/dev/null; then
  sudo apt install nginx -y
fi
# 判断虚拟主机配置文件夹是否存在
if [ ! -d "/etc/nginx/vhosts" ]; then
    sudo mkdir -p /etc/nginx/vhosts
fi
# 增加虚拟目录
if [ ! `grep "vhosts" /etc/nginx/nginx.conf  &>> error.txt` ]; then
     sed -i '/include \/etc\/nginx\/sites-enabled\/\*;/a\  \   \  \ include vhosts/*.conf;' /etc/nginx/nginx.conf
fi
# 判断项目文件夹是否存在
if [ ! -d "/data/web" ]; then
    sudo mkdir -p /data/web
    sudo chown -R www-data:www-data /data/web
fi
server {
        listen       80;
        server_name  jenkins.520cgy.com;
        location / {
            proxy_pass http://127.0.0.1:8081;
        }
}
